package com.share.thread.pc;

import java.util.Random;

/**
 * @desc: 生产者
 * @author:caifan
 * @date:2022/1/28
 */
public class Producer03 implements Runnable {

    private MyBlocking<Integer> queue;
    private Random random = new Random();
    public Producer03(MyBlocking<Integer> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                int i = random.nextInt(1000);
                queue.put(i);
                System.out.println("producer:" + i + "-" + Thread.currentThread().getName());
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
